fix: better management of relative paths#608
Conversation
d972d00 to
45b01a7
Compare
- Improve management of relative paths, calculating them once. - Set outdir globally and reuse. - Reduce code duplication (still lots to improve) - Move flags processing to helper func when present - Improve UX on some error messages, help messages and debug messages - Normalize words in help messages Fixes #508
- Fix logic on some commands now that we have outdir always set to an absolute path - Fix some UX messages
Put var name between qoutes in the error message to make evident if there is a space in the env var name, for exmaple.
mention that the changes are not potentially safe, the user already knows they are applying new configuration.
45b01a7 to
ea469c0
Compare
kriive
left a comment
There was a problem hiding this comment.
some nitpicks but overall LGTM!
define `err` variable in func output instead of standalone Co-authored-by: Manuel Romei <manuel.romei@reevo.it>
kriive
left a comment
There was a problem hiding this comment.
Linter's failing on my idiomatic suggestions ¯_(ツ)_/¯ let's revert my code suggestions and follow the linter (which I do not agree with btw lol)
This reverts commit a9be1df. The change did not pass the linting checks.
Co-authored-by: Manuel Romei <manuel.romei@reevo.it>
Error out when phase and post-apply-phases are set, post-apply-phases will be ignored when phase is set. We should probably support both flags simultaneously in the future, but now at least we error out instead of ignoring the post-apply-phases flag. Relates: #602
Yeah, I liked your suggestions. It looked cleaner, but the linter has a point: https://github.com/FireFart/nonamedreturns I also added a check for when |
Summary 💡
Fixes #508
Description 📝
The main goal of this PR is to fix an issue when setting outdir to a relative path (like
.) resulted in an error on the apply command (and others).The issue was caused by several problems, but mainly:
outdirwas calculated as a permanent pre-run of the root command, but overwritten laterIn this PR I tried to fix these 3 issues, by having the root command update the flags with the right values and reusing them when possible. Also, in each command I moved the logic that handles the flags parsing to the dedicated function (if it was present).
I also took the chance to improve the UX, by adding some details to the messages that we show the user, adding some more debug logs, and unifying the style of the help messages.
I tried to not do a complete overhaul of the code to avoid breaking stuff and making this PR self-contained. We should make more of this iterative improvements. I think that this PR is a step in the right direction.
Breaking Changes 💔
None
Tests performed 🧪
Future work 🔧
There's still a lot of code duplication, the flags processing can probably be improved and there should be a way to handle them more smartly. We use almost the same flags on several commands.